package cmd

import (
	"github.com/spf13/cobra"
	"my189go/pkg/webdav"
)

var webdavCmd = &cobra.Command{
	Use:   "webdav",
	Short: "start webdav server, arg: port prefix: /webdav",
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		prefix := "/189"
		if len(args) > 1 {
			prefix = args[1]
			if prefix[0] != '/' {
				prefix = "/" + prefix
			}
		}
		webdav.Serve(args[0], App(), prefix)
	},
}
